<template>
  <div class="page"></div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useStore } from '@/store/index'
import { showToast, showError } from 'js/utils'
import api from 'js/api'
import md5 from 'js-md5'

const router = useRouter()
const route = useRoute()
const store = useStore()

login()

// 登录
async function login() {
  const params = {
    walletAddress: md5(window.fromAddress) + window.fromAddress.slice(5, 14),
    // walletAddress: '5443dcf527f5a37767df9a8143397fcbv95h9mgaq',
    // walletAddress: '364eee597136abfdebfdca7ed3b6c0f28lk494j0f',
  }

  const { code, data } = await api.login(params)

  if (code === 200) {
    store.setToken(data)
    router.replace('/')
  } else if (code === 500) {
    router.replace('/register')
  }
}
</script>

<style lang="scss" scoped>
.page {
  background: url('@/assets/img/bg.jpg') no-repeat center / cover;
}
</style>
